
import {axios_, initUser} from './common'
// {spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.1)'}
import { Loading } from 'element-ui';


let myuser = initUser || {};
export default {
  state: {
    info: myuser,
    loadingStart:null,
  },
  getters: {

  },
  mutations: {
    revise(state,obj){
      state.info = {...state.info,...obj};
      // sessionStoragePut('user',state.info)
    },
    starLoading:(state) => {
      state.loadingStart = Loading.service({spinner: 'el-icon-loading', background: 'rgba(255, 255, 255, 0.95)'})
    },
    closeLoading:(state) => {
      state.loadingStart.close()
    }
  },
  actions: {
    // 公众号端合同管理 查询
    userOrder_getOrder(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/siteUserOrder/getOrder',{
        ...obj
      }).then(res => {
        console.log(res);
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      }).catch(err => {
        alert('数据已失效')
      })
    },
    // 公众号端租户还款计划 查询
    getInstalmentOrder(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/instalment/getInstalmentOrder',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },

    // POST /Wechat/instalment/updateOrderStatus
    // 更新本期还款状态

    getInstalmentOrder(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/instalment/updateOrderStatus',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },

    // 公众号端合同管理 确认
    verifyOrder(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/siteUserOrder/verifyOrder',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },
    // 公众号端租户个人信息维护 维护
    supplementUserMsg(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/userMsg/supplementUserMsg',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },
    // 公众号端租户个人信息维护 查询
    getUserMsg(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/userMsg/getUser',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },

    // 获取验证码
    getSmsCode(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/bankCard/getSmsCode',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },

    // /Wechat/bankCard/supplementUserMsg
    // 租户绑定银行卡
    supplementUserMsgBank(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/bankCard/supplementUserMsg',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },
    // 还款计划  查询
    getInstalmentOrder(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/instalment/getInstalmentOrder',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },
    // POST /Wechat/recharge/getAuthCode 充值获取 验证码
    getAuthCode(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/recharge/getAuthCode',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },

    // POST /Wechat/recharge/authPayConfirm 确认充值
    authPayConfirm(state,obj){
      console.log("obj:",obj);
      return axios_.post('Wechat/recharge/authPayConfirm',{
        ...obj
      }).then(res => {
          if(res.status && res.status == 200){
            return JSON.parse(res.request.response);
          }else{
            alert('eeeee error')
          }
      }).then(res => {
        return res;
      })
    },

  }
}
